package test.util

import scala.collection.mutable.ListBuffer

class AssertionsCollector {
  var assertions = new ListBuffer[org.specs2.execute.FailureException]
  
  def apply(f: => Unit) = try f catch {
    case e: org.specs2.execute.FailureException => assertions.synchronized {
      assertions += e
    }
  }
  
  def replay(): org.specs2.execute.Result = {
    assertions.foreach { assertion => throw assertion }
    org.specs2.execute.Success("")
  }
}
